package com.sancorseguros.nova.selenium.pageobject;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Actions;

import com.sancorseguros.nova.selenium.config.StaticSelenium;

public class EnterLossDetailPage extends AbstractPage {
	
	private static final long serialVersionUID = -7335390716063039345L;
	
	private WebDriver driver;
	
    public EnterLossDetailPage(WebDriver driver) throws InterruptedException {  
        super();  
        this.setDriver(driver);
        this.setTitle(StaticSelenium.TITLE_LOSS_DETAIL);
	}
    
	public void doCompleteForm(String date, String time) {
		Actions action = new Actions(this.getDriver());
		this.getDriver().findElement(By.id("main")).click();
		action.sendKeys(Keys.TAB).sendKeys(Keys.TAB).sendKeys(date).perform();
		action.sendKeys(Keys.TAB).sendKeys(time).perform();
	}
    
	public CreatedLossPage goToCreateLoss(WebDriver driver) throws InterruptedException {
		Actions action = new Actions(this.getDriver());
		action.sendKeys(Keys.TAB).sendKeys(Keys.TAB).sendKeys(Keys.TAB).sendKeys(Keys.SPACE).perform();
		return new CreatedLossPage(driver);
	}
		
	public WebDriver getDriver() {
		return driver;
	}
	
	public void setDriver(WebDriver driver) {
		this.driver = driver;
	}
	
	@Override
	public void validatePage() {
		assertTrue(StaticSelenium.INVALID_TEXT, this.isTextPresent(this.getDriver(), StaticSelenium.TITLE_LOSS_DETAIL));
	}

	
}
